package cn.hx.admin.service.impl;

import cn.hx.admin.entity.OperLog;
import cn.hx.admin.dao.OperLogDao;
import cn.hx.admin.service.OperLogService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * 操作日志记录(OperLog)表服务实现类
 *
 * @author makejava
 * @since 2023-12-13 20:12:32
 */
@Service("operLogService")
public class OperLogServiceImpl implements OperLogService {
    @Resource
    private OperLogDao operLogDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public OperLog queryById(Integer id) {
        return this.operLogDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param operLog 筛选条件
     * @return 查询结果
     */
    @Override
    public List<OperLog> queryByPage(OperLog operLog) {
        List<OperLog> operLogs = this.operLogDao.queryAllByLimit(operLog);
        return operLogs;
    }

    /**
     * 新增数据
     *
     * @param operLog 实例对象
     * @return 实例对象
     */
    @Override
    public OperLog insert(OperLog operLog) {
        this.operLogDao.insert(operLog);
        return operLog;
    }

    /**
     * 修改数据
     *
     * @param operLog 实例对象
     * @return 实例对象
     */
    @Override
    public OperLog update(OperLog operLog) {
        this.operLogDao.update(operLog);
        return this.queryById(operLog.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.operLogDao.deleteById(id) > 0;
    }
}
